/**
 * ==================== api 请求 ====================
 */
import { URLS } from './urls';
import http from './request'


export const API = {
    // 获取首页轮播图数据
    homeBanner() {
        return new Promise((resolve, reject) => {
            http.httpGet({
                loading: '加载中...',
                url: URLS.home_Banner,
                params: {},
                success: (result: any) => {
                    resolve(result)
                },
                fail: (err: any) => {
                    reject(err)
                }
            })
        })
    },

    // 获取首页公告数据
    wallNewsList(select: boolean,) {
        return new Promise((resolve, reject) => {
            http.httpGet({
                url: URLS.wall_NewsList,
                params: {
                    select: select
                },
                success: (result: any) => {
                    resolve(result)
                },
                fail: (err: any) => {
                    reject(err)
                }
            })
        })
    },

    // 壁纸资讯公告详情
    wallNewsDetail(id: string,) {
        return new Promise((resolve, reject) => {
            http.httpGet({
                loading: '加载中...',
                url: URLS.wallNewsDetail,
                params: {
                    id: id
                },
                success: (result: any) => {
                    resolve(result)
                },
                fail: (err: any) => {
                    reject(err)
                }
            })
        })
    },

    // 获取首页每日推荐壁纸
    randomWall() {
        return new Promise((resolve, reject) => {
            http.httpGet({
                url: URLS.random_Wall,
                params: {},
                success: (result: any) => {
                    resolve(result)
                },
                fail: (err: any) => {
                    reject(err)
                }
            })
        })
    },

    // 获取壁纸分类
    classify(pageNum?: number, pageSize?: number, select?: boolean) {
        return new Promise((resolve, reject) => {
            http.httpGet({
                loading: '加载中...',
                url: URLS.classify,
                params: {
                    pageNum: pageNum,
                    pageSize: pageSize,
                    select: select
                },
                success: (result: any) => {
                    resolve(result)
                },
                fail: (err: any) => {
                    reject(err)
                }
            })
        })
    },

    // 分类中壁纸列表（分类详情）
    wallList(classid: string, pageNum: number, pageSize: number) {
        return new Promise((resolve, reject) => {
            http.httpGet({
                loading: '加载中...',
                url: URLS.wallList,
                params: {
                    classid: classid,
                    pageNum: pageNum,
                    pageSize: pageSize,
                },
                success: (result: any) => {
                    resolve(result)
                },
                fail: (err: any) => {
                    reject(err)
                }
            })
        })
    },

    // 为壁纸评分
    setupScore(classid: string, wallId: string, userScore: string) {
        return new Promise((resolve, reject) => {
            http.httpGet({
                url: URLS.setupScore,
                params: {
                    classid: classid,
                    wallId: wallId,
                    userScore: userScore,
                },
                success: (result: any) => {
                    resolve(result)
                },
                fail: (err: any) => {
                    reject(err)
                }
            })
        })
    },

    // 为壁纸评分
    downloadWall(classid: string, wallId: string) {
        return new Promise((resolve, reject) => {
            http.httpGet({
                url: URLS.downloadWall,
                params: {
                    classid: classid,
                    wallId: wallId
                },
                success: (result: any) => {
                    resolve(result)
                },
                fail: (err: any) => {
                    reject(err)
                }
            })
        })
    },

    // 用户个人信息
    userInfo() {
        return new Promise((resolve, reject) => {
            http.httpGet({
                loading: '加载中...',
                url: URLS.userInfo,
                params: {},
                success: (result: any) => {
                    resolve(result)
                },
                fail: (err: any) => {
                    reject(err)
                }
            })
        })
    },

    // 我的评分、下载列表
    userWallList(type: string, pageNum: number, pageSize: number) {
        return new Promise((resolve, reject) => {
            http.httpGet({
                loading: '加载中...',
                url: URLS.userWallList,
                params: {
                    type: type,
                    pageNum: pageNum,
                    pageSize: pageSize,
                },
                success: (result: any) => {
                    resolve(result)
                },
                fail: (err: any) => {
                    reject(err)
                }
            })
        })
    },

    // 搜索壁纸
    searchWall(keyword: string, pageNum: number, pageSize: number) {
        return new Promise((resolve, reject) => {
            http.httpGet({
                loading: '加载中...',
                url: URLS.searchWall,
                params: {
                    keyword: keyword,
                    pageNum: pageNum,
                    pageSize: pageSize,
                },
                success: (result: any) => {
                    resolve(result)
                },
                fail: (err: any) => {
                    reject(err)
                }
            })
        })
    },

    // 专题列表
    subjectList(pageNum: number, pageSize: number) {
        return new Promise((resolve, reject) => {
            http.httpGet({
                loading: '加载中...',
                url: URLS.subjectList,
                params: {
                    pageNum: pageNum,
                    pageSize: pageSize,
                },
                success: (result: any) => {
                    resolve(result)
                },
                fail: (err: any) => {
                    reject(err)
                }
            })
        })
    },

    // 专题详情
    subjectDetail(id: string) {
        return new Promise((resolve, reject) => {
            http.httpGet({
                loading: '加载中...',
                url: URLS.subjectDetail,
                params: {
                    id: id
                },
                success: (result: any) => {
                    resolve(result)
                },
                fail: (err: any) => {
                    reject(err)
                }
            })
        })
    },

    // 萌宠大集合
    petShow(type: string, pageNum: number, pageSize: number) {
        return new Promise((resolve, reject) => {
            http.httpGet({
                loading: '加载中...',
                url: URLS.petShow,
                params: {
                    type: type,
                    pageNum: pageNum,
                    size: pageSize,
                },
                success: (result: any) => {
                    resolve(result)
                },
                fail: (err: any) => {
                    reject(err)
                }
            })
        })
    },

    // 淘宝买家秀
    taoShow(pageNum: number, pageSize: number) {
        return new Promise((resolve, reject) => {
            http.httpGet({
                loading: '加载中...',
                url: URLS.taoShow,
                params: {
                    pageNum: pageNum,
                    size: pageSize,
                },
                success: (result: any) => {
                    resolve(result)
                },
                fail: (err: any) => {
                    reject(err)
                }
            })
        })
    },
};